@extends('admin.app')
@section('content')
    <link rel="stylesheet" href="/css/icon/iconfont-0130.css">
    <link rel="stylesheet" href="/addons/icheck-1.x/skins/square/green.css">
    <link rel="stylesheet" href="/css/admin/mobileSelect.css">
    @if($skinid == 3)
        <link rel="stylesheet" href="/css/admin/add-tips.css?v={{time()}}">
    @elseif($skinid == 1)
        <link rel="stylesheet" href="/css/theme-blue/admin/add-tips.css?v={{time()}}">
    @elseif($skinid == 2)
        <link rel="stylesheet" href="/css/theme-pink/system/iconfont-pink.css">
        <link rel="stylesheet" href="/css/theme-pink/admin/add-tips.css?v={{time()}}">
    @endif

    <script src="/addons/icheck-1.x/icheck.min.js"></script>
    <div class="mian-container">
        <div class="tip-con">
            <ul class="tip-list">
                @foreach($Tips as $key=>$val)
                <li  style="background: {{$val->color}}"><span></span>{{$val->name}}<i class="icon iconfont icon-xiugai"  data-id="{{$val->id}}"  data-name="{{$val->name}}"></i><i class="icon iconfont icon-chahao"  id="{{$val->id}}"></i></li>
                    @endforeach
            </ul>
        </div>
        <div class="tips-div">
            <a class="tip-btn"><i class="icon iconfont icon-jiahao"></i>创建新标签</a>
        </div>

        @if($user->getRole()==9)
            @include('sysadmin.admin-caidan')
        @else
            <div class="reful-tabbar">
                <a href="{{url('/user/performance/perf')}}" class="tabbar-item">
                    <p style="line-height: 65px;" class="tabbar-label">返回个人用户界面</p>
                </a>
            </div>

        @endif
    </div>

    <div class="shadow-hidden"></div>
    <div class="hidden-sec">
        <div class="popup"><h3>创建标签</h3><i class="weui-icon-cancel"></i></div>
        <p>请为新标签输入名称</p>
        <input type="text" value="" name="pro-name" class="input text-input">
        <input type="hidden" value="" name="pro-id" class="input text-input">
        <a class="sub-mit modi-nickname" href="javascript:void(0);">保存</a>
    </div>
    <div class="fix-message">
        @if($skinid == 3)
            <img src="/img-theme-pink/que-3.png">
        @elseif($skinid == 1)
            <img src="/img-theme-pink/que-2.png">
        @elseif($skinid == 2)
            <img src="/img-theme-pink/que-1.png">
        @endif
    </div>
    <script src="/js/mobileSelect.js"></script>
    <script>
        $(document).ready(function () {
            $('.fix-message img').click(function () {
                $.alert("本系统以创建项目，填写完成值的方式来表现员工的绩效值。为方便统计和类比，对于明确的，需要多次填写的考核项目，可创建低于6个字的标签，填写时选择标签类别再填写；其它类别的考核项目，可直接创建项目进行填写。", "提示");
            })
            $('.set-btn').click(function () {
                $('.set-hidden').toggle();
            })
            $('.admin-item').click(function(){
                $('.front-show-hidden').toggle();
            })
            $('.kaohe-item').click(function () {
                $('.show-hidden').toggle();
            })
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });

            $('.tip-btn').click(function () {
                $('.hidden-sec').css('display','block');
                $('.shadow-hidden').css('display','block');
            });

            //确定，提交信息取input信息，ajax
            $('.sub-mit').click(function () {
                name=$('.text-input').val();
                var id = $('input[name=pro-id]').val();
                if(name.length>12){
                    $.alert("项目名请在12字以内！");
                }else{


                    var url='/admin/tips';
                    $.ajax({
                        type: 'post',
                        cache: 'false',
                        url: url,
                        data: 'name=' + name + '&id=' +id,
                        dataType: 'json',
                        success: function (data) {
                            if (data.status == 'success') {
                                if(id > 0){
                                    window.location.reload();
                                }else{
                                    window.location.reload();
                                    $('.tip-list').append('<li style="background: '+data.data.color+'">' +
                                            '<span></span>' +
                                            name +
                                            '<i class="icon iconfont icon-chahao"></i>' +
                                            '</li>');
                                    $('.hidden-sec').css('display','none');
                                    $('.shadow-hidden').css('display','none');
                                }

                            } else {
                                $.toptip(data.msg,'error');

                            }
                        },
                        error: function () {
                            $.toptip('网络异常请重试','warning');
                        }
                    });





                }
            })
            //删除，提交信息取input信息，ajax
            $('body').on('click','.icon-chahao',function(){
                var that=this;
                t_id=that.id;
                $.confirm({
                    title: '删除',
                    text: '确认删除该标签?删除后该标签下的业绩将不可显示',
                    onOK: function () {
                        //点击确认
                        var url='/admin/tips/'+t_id;
                        $.ajax({
                            type: 'DELETE',
                            cache: 'false',
                            url: url,
                            dataType: 'json',
                            success: function (data) {
                                if (data.status == 'success') {
                                    $(that).parent().remove();

                                } else {
                                    $.toptip(data.msg,'error');

                                }
                            },
                            error: function () {
                                $.toptip('网络异常请重试','warning');
                            }
                        });
                    },
                    onCancel: function () {

                    }
                });
            });

            //删除，提交信息取input信息，ajax
            $('body').on('click','.icon-xiugai',function(){
                var that=this;
                var t_id = $(that).attr('data-id');
                var t_name = $(that).attr('data-name');
                $('input[name=pro-id]').val(t_id);
                $('input[name=pro-name]').val(t_name);
                $('.hidden-sec').css('display','block');
                $('.shadow-hidden').css('display','block');
            });


            $('.hidden-sec .popup i').click(function () {
                $('.hidden-sec').css('display','none');
                $('.shadow-hidden').css('display','none');
            })
        })
    </script>
@endsection
